package cn.lijiguo.concurrency.part1.ch06;

import java.time.Duration;
import java.time.Instant;

/**
 * ThreadStopForce
 * 优雅的停止线程测试
 * @author lijiguo
 * @date 2019/12/13 16:32
 */
public class ThreadStopForce {

    public static void main(String[] args) {
        ThreadService threadService = new ThreadService();

        Instant start = Instant.now();
        threadService.execute(() -> {
//            while(true) {
//
//            }

            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        threadService.shutdown(10000);
        Instant end = Instant.now();
        System.out.println("任务执行时间：" + Duration.between(start, end).toMillis());
    }
}
